<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改专家消息')" />
    <th:block th:include="include :: select2-css" />
    <!--文件上传-->
    <link th:href="@{/layui-v2.5.4/css/layui.css}" rel="stylesheet"/>
    <style type="text/css">
        .uploader-list {
            margin-left: -15px;
        }

        .uploader-list .info {
            position: relative;
            margin-top: -25px;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            height: 25px;
            text-align: center;
            display: none;
        }

        .uploader-list .handle {
            position: relative;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            text-align: right;
            height: 18px;
            margin-bottom: -18px;
            display: none;
        }

        .uploader-list .handle i {
            margin-right: 5px;
        }

        .uploader-list .handle i:hover {
            cursor: pointer;
        }

        .uploader-list .file-iteme {
            margin: 12px 0 0 15px;
            padding: 1px;
            float: left;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-edit" th:object="${expertInfo}">
            <input name="expertId" th:field="*{expertId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">会员ID：</label>
                <div class="col-sm-8">
                   <!-- <input name="memberId" th:field="*{memberId}" class="form-control" type="text">-->
                    <select id="memberId" name="memberId" class="form-control"  th:with="memberInfoList=${@memberInfo.selectMemberInfoListForqd()}"  th:field="*{memberId}">
                        <option th:each="memberinfo : ${memberInfoList}" th:text="${memberinfo.nikeName}"
                                th:value="${memberinfo.memberId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">个人照片：</label>
                <div class="col-sm-8">
                   <!-- <input name="personalPhoto" th:field="*{personalPhoto}" class="form-control" type="text">-->
                            <div class="layui-upload">
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 100%">
                                    预览图：
                                    <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list">

                                    </div>
                                </blockquote>
                                <button type="button" class="layui-btn" id="test2">主图上传</button>
                            </div>
                            <input id="personalPhoto" name="personalPhoto"  type="hidden">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">真实姓名：</label>
                <div class="col-sm-8">
                    <input name="realName" th:field="*{realName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">手机号：</label>
                <div class="col-sm-8">
                    <input name="phone" th:field="*{phone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <input name="email" th:field="*{email}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">所在地编码：</label>
                <div class="col-sm-8">
                    <input name="areaCode" th:field="*{areaCode}" class="form-control" type="text" required>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label is-required">擅长专业作物编码：</label>
                <div class="col-sm-8">
                    <input name="cropCode" th:field="*{cropCode}" class="form-control" type="text" required>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">擅长专业作物编码：</label>
                <div class="col-sm-8">
                    <select name="cropCode" id="cropCode" class="form-control select2-multiple" multiple th:with="cropDictList=${@cropdict.selectCropDictByPartant(1)}">
                        <option th:each="cropdicta : ${cropDictList}" th:text="${cropdicta.cropName}"
                                th:value="${cropdicta.cropId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">擅长领域编码：</label>
                <div class="col-sm-8">
                    <select name="regionCode" id="regionCode" class="form-control select2-multiple" multiple th:with="cropDictList=${@cropdict.selectCropDictByPartant(0)}">
                        <option th:each="cropdicta : ${cropDictList}" th:text="${cropdicta.cropName}"
                                th:value="${cropdicta.cropId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">个人简介：</label>
                <div class="col-sm-8">
                    <textarea name="personalProfile" th:field="*{personalProfile}" class="form-control" type="text"></textarea>
                </div>
            </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">审核状态：</label>
                        <div class="col-sm-8">
                            <select name="verifyStatus" id="verifyStatus" class="form-control" th:field="*{verifyStatus}">
                                <option value="1">审核通过</option>
                                <option value="0">审核失败</option>
                            </select>
                        </div>
                    </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">专家注册时所属系统名称：</label>
                <div class="col-sm-8">
                    <input name="sysName" th:field="*{sysName}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript" th:inline="javascript">
        var ctx  = [[${#request.getContextPath()}]];
        var questionImages = "";

        var prefix = ctx + "/agriculture/info";
        $("#form-info-edit").validate({
            focusCleanup: true
        });


        /*select2下拉多选回显*/
        var  arr = [[${expertInfo.cropCode}]];
        $("#cropCode").val(arr.split(",")).trigger("change");

        var  arr2 = [[${expertInfo.regionCode}]];
        $("#regionCode").val(arr2.split(",")).trigger("change");


        var  upurl=ctx + "/oss/upload";
        //上传图片
        layui.use('upload', function () {
            var upload = layui.upload;
            upload.render({
                elem: '#test2'
                , url: upurl
                , multiple: true
                , accept: "images"
                , acceptMime: "image/*"
                , before: function (obj) {
                    layer.msg('图片上传中...', {
                        icon: 16,
                        shade: 0.01,
                        time: 0
                    })
                }
                , done: function (res) {
                    layer.close(layer.msg());//关闭上传提示窗口
                    questionImages = res.data ;
                    $("#personalPhoto").val(questionImages);
                    //上传完毕
                    $('#uploader-list').html(
                        '<div id="" class="file-iteme">' +
                        '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                        '<img style="width: 100px;height: 100px;" src=' + res.data + '>' +
                        '</div>'
                    );
                }
            });
        })


        $(document).on("mouseenter mouseleave", ".file-iteme", function (event) {
            if (event.type === "mouseenter") {
                //鼠标悬浮
                $(this).children(".info").fadeIn("fast");
                $(this).children(".handle").fadeIn("fast");
            } else if (event.type === "mouseleave") {
                //鼠标离开
                $(this).children(".info").hide();
                $(this).children(".handle").hide();
            }
        });
        // 删除图片
        $(document).on("click", ".file-iteme .handle", function (event) {
            $(this).parent().remove();
            questionImages="";
            $("#mainImg").val(questionImages);

        });

        var picturesString=[[${expertInfo.personalPhoto}]];
        console.log(picturesString)
        if(picturesString!=null){
            $('#uploader-list').append(
                '<div id="" class="file-iteme">' +
                '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                '<img style="width: 100px;height: 100px;" src=' + picturesString + '>' +
                '</div>'
            );
        }



        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-info-edit').serialize());
            }
        }
    </script>
</body>
</html>